//
//  LXWhiteColorNavigationController.m
//  bgms_d
//
//  Created by lachesis-zhu on 03/07/2017.
//  Copyright © 2017 lachesis-zhu. All rights reserved.
//

#import "LXWhiteColorNavigationController.h"

@interface LXWhiteColorNavigationController ()

@end

@implementation LXWhiteColorNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationBar setBackgroundImage:[UIImage imageWithColor:kAppThemeColor] forBarMetrics:UIBarMetricsDefault];
    [self.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor clearColor]]];
    [self.navigationBar setTitleTextAttributes:@{NSFontAttributeName : [UIFont lx_systemFontOfSize:20.0f],
                                                 NSForegroundColorAttributeName : kAppNormalTextColor}];
}
/**
 *  override 重写 push
 *
 *  @param viewController 要push的viewController
 *  @param animated       是、否
 */
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [super pushViewController:viewController animated:animated];
    
    self.pushViewController = viewController;
    if(self.viewControllers.count > 1 && !viewController.navigationItem.leftBarButtonItem)
    {
        viewController.navigationItem.leftBarButtonItem = [self leftBackItem];//返回键
    }
}


/**
 *  返回键自定义
 *
 *  @return 返回键
 */
-(UIBarButtonItem *)leftBackItem
{
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(leftBackAction)];
    
    return backItem;
}

/**
 *  返回事件
 */
-(void)leftBackAction
{
    self.pushViewController = self.visibleViewController;
    if(self.pushViewController && [self.pushViewController respondsToSelector:@selector(viewControllerDidPopup)])
    {
        [self.pushViewController performSelector:@selector(viewControllerDidPopup)];
    }
    
    [self performSelector:@selector(popViewControllerAnimated:)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
